/**
 * @FileDescription 删除地图要素
 * @Author 祝小文
 * @Date 2022-11-24 11:08
 */

/** 通过PatName移除上图要素 */
export const removeTempMapFactor = (id: any) => {
  window.GWarCircle.removeByPatName(id)
  window.GWarStickLabel.removeByPatName(id)
  window.GWarSign.removeByPatName(id)
  window.GWarCar.removeByPatName(id)
  window.GWarPolygon.removeByPatName(id)
  window.GWarPolyline.removeByPatName(id)
}

//移除上一次要素选中效果
export const removeLastMapFactorActive = () => {
  const { bzlx, name }: any = useFirefightPlotStore().activeMapFactor
  if (bzlx && name) {
    //---------- 1. 圆 ----------
    if (useFirefightPlotStore().bzlxWarCircle.includes(bzlx)) {
      window.GWarCircle.setActive(name, false)
    }

    //---------- 2. 文字 ----------
    else if (useFirefightPlotStore().bzlxWarStickLabel.includes(bzlx)) {
      window.GWarStickLabel.setActive(name, false)
    }

    //---------- 3. 标牌 ----------
    else if (useFirefightPlotStore().bzlxWarSign.includes(bzlx)) {
      window.GWarSign.setActive(name, false)
    }

    //---------- 4. 消防车标牌 ----------
    else if (useFirefightPlotStore().bzlxWarCar.includes(bzlx)) {
      window.GWarCar.setActive(name, false)
    }

    //---------- 5. 线 ----------
    else if (useFirefightPlotStore().bzlxWarPolyline.includes(bzlx)) {
      window.GWarPolyline.setActive(name, false)
    }

    //---------- 6. 多边形 ----------
    else if (useFirefightPlotStore().bzlxWarPolygon.includes(bzlx)) {
      window.GWarPolygon.setActive(name, false)
    }
  }
}

//移除当前地图要素
export const removeActiveMapFactor = (bzlx: any, name: any) => {
  //---------- 1. 圆 ----------
  if (useFirefightPlotStore().bzlxWarCircle.includes(bzlx)) {
    window.GWarCircle.removeByName(name)
  }

  //---------- 2. 文字 ----------
  else if (useFirefightPlotStore().bzlxWarStickLabel.includes(bzlx)) {
    window.GWarStickLabel.removeByName(name)
  }

  //---------- 3. 标牌 ----------
  else if (useFirefightPlotStore().bzlxWarSign.includes(bzlx)) {
    window.GWarSign.removeByName(name)
  }

  //---------- 4. 消防车标牌 ----------
  else if (useFirefightPlotStore().bzlxWarCar.includes(bzlx)) {
    window.GWarCar.removeByName(name)
  }

  //---------- 5. 线 ----------
  else if (useFirefightPlotStore().bzlxWarPolyline.includes(bzlx)) {
    window.GWarPolyline.removeByName(name)
  }

  //---------- 6. 多边形 ----------
  else if (useFirefightPlotStore().bzlxWarPolygon.includes(bzlx)) {
    window.GWarPolygon.removeByName(name)
  }
}
